﻿using ControllerLayer;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using ModelLayer;
using System;

namespace UnitTest
{
    /// <summary>
    /// Summary description for UnitTestReservation
    /// </summary>
    [TestClass]
    public class UnitTestReservation
    {
        private StationCtr _stationCtr;
        private ReservationCtr _reservationCtr;
        private PersonCtr _personCtr;
        private long _resId;

        /// <summary>
        /// Tests the create reservation.
        /// </summary>
        [TestMethod]
        public void TestCreateReservation()
        {
            _stationCtr = new StationCtr();
            _personCtr = new PersonCtr();
            _reservationCtr = new ReservationCtr();

            Station startStation = _stationCtr.GetStation(1);
            Station endStation = _stationCtr.GetStation(23);
            Customer customer = _personCtr.GetCustomer(0);
            Reservation reservation = _reservationCtr.CreateReservationUsingDijkstras(startStation, endStation, customer, DateTime.Now);

            _resId = reservation.Id;
            Assert.AreNotEqual(_resId, -1);
        }

        /// <summary>
        /// Tests the update reservation.
        /// </summary>
        [TestMethod]
        public void TestUpdateReservation()
        {
            Reservation tmpReservation = _reservationCtr.GetReservation(_resId);
            tmpReservation.Date = DateTime.Now.AddMonths(1);
            int rc = _reservationCtr.UpdateReservation(tmpReservation);

            Assert.AreNotEqual(-1, rc);
        }

        /// <summary>
        /// Tests the delete reservation.
        /// </summary>
        [TestMethod]
        public void TestDeleteReservation()
        {
            Reservation tmpReservation = _reservationCtr.GetReservation(_resId);
            int rc = _reservationCtr.CancelReservation(tmpReservation);

            Assert.AreNotEqual(-1, rc);
        }
    }
}